import { useScroll } from "ahooks"

/**
 * @param max 最大透明度
 * @description 监听滚动事件，返回当前滚动的距离和透明度
 */
export function useOpacity(max?: number) {
    const scroll = useScroll(() => document)
    const opacity = Math.min((scroll?.top ?? 0) / 280, max ?? 1)
    return {
        opacity,
        scroll,
    }
}
